package models.mappers;

import java.util.List;
import java.util.Map;

import models.BackInfo;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import vos.BackInfoSearchVo;
import vos.BackInfoVo;

public interface BackInfoMapper {
	/**
	 * 统计返款信息总数
	 *
	 * @Title: countBackInfo 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countBackInfo(BackInfoSearchVo vo);
	/**
	 * 统计返款信息列表
	 *
	 * @Title: listBackInfo 
	 * @param vo
	 * @return
	 * @return: List<BackInfoVo>
	 */
	List<BackInfoVo> listBackInfo(BackInfoSearchVo vo);
	/**
	 * 批量返款
	 *
	 * @Title: betchBack 
	 * @param map
	 * @return: void
	 */
	void betchBack(Map<String, Object> map);
	/**
	 * 根据id集合获取返款信息
	 *
	 * @Title: getByIds 
	 * @param map
	 * @return
	 * @return: List<BackInfoVo>
	 */
	List<BackInfoVo> getByIds(Map<String, Object> map);
	/**
	 * 根据id获取返款信息
	 *
	 * @Title: getById 
	 * @param id
	 * @return
	 * @return: BackInfoVo
	 */
	@Select("select * from backinfo_view where id=#{id}")
	BackInfoVo getById(Long id);
	/**
	 * 修改返款信息
	 *
	 * @Title: updateBackInfo 
	 * @param backinfo
	 * @return: void
	 */
	@Update("update backinfo set backtotal=#{backtotal},backtime=#{backtime},"
			+ "backname=#{backname},reason=#{reason},isback=true,remark=#{remark}"
			+ " where id=#{id} and isreject=false")
	void updateBackInfo(BackInfo backinfo);
	/**
	 * 批量驳回
	 *
	 * @Title: betchReject 
	 * @param map
	 * @return: void
	 */
	void betchReject(Map<String, Object> map);
	/**
	 * 驳回
	 *
	 * @Title: reject 
	 * @param map
	 * @return: void
	 */
	@Update("update "
			+ BackInfo.TABLE_NAME
			+" set isreject=true,modifytime=#{modifytime},modifyname=#{modifyname},rejreason=#{rejreason}"
			+ " where id=#{id}")
	void reject(Map<String, Object> map);
	/**
	 * 导出excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<BackInfoVo>
	 */
	List<BackInfoVo> exportXls(BackInfoSearchVo vo);
	/**
	 * 对返款信息进行重新统计
	 *
	 * @Title: reCount 
	 * @param map
	 * @return: void
	 */
	void reCount(Map<String, Object> map);
	/**
	 * 更新驳回返款为未驳回
	 *
	 * @Title: updateReject 
	 * @param map
	 * @return: void
	 */
	void updateReject(Map<String, Object> map);
	/**
	 * 根据id集合获取返款列表
	 *
	 * @Title: getBackByIds 
	 * @param map
	 * @return
	 * @return: List<BackInfo>
	 */
	List<BackInfo> getBackByIds(Map<String, Object> map);
	/**
	 * 根据门店id和月份获取数据
	 *
	 * @Title: getFData 
	 * @param shopid
	 * @param bmonth
	 * @return
	 * @return: BackInfoVo
	 */
	@Select("select shopid,shopname,cmonth,isreject,dealerid,dealername,isback from backinfo_view where shopid=#{shopid} and cmonth=#{cmonth} and isreject=false")
	BackInfoVo getFData(@Param("shopid")String shopid,@Param("cmonth") String bmonth);
	
}
